<?php 
/**
 * 宴会介绍model
 * @author Administrator
 *
 */
class FeastModel extends Model
{
	//数据表
	protected $trueTableName = 'td_feast';
	
	//设置主键
	protected  $key = 'td_id';
	
	//获取数据条数
	public function getCount($seek='')
	{
	
		//条件
		$where = '1=1';
	
		return $this->where($seek.$where)->count();
	
	}
	/**
	 * 获取列表
	 * @param unknown $page 分页参数
	 * @param unknown $seek 搜索参数
	 * @return Ambigous <mixed, string, boolean, NULL, unknown, multitype:, multitype:multitype: , void, object>
	 */
	public function getListAll($page, $seek='')
	{
		//字段
		$field = array(
				'td_id',
				'td_name',
				'td_head_img',
				'td_intro_img',
				'td_text',
				'td_content',
				'sort',
				'add_time',
		);
	
		//条件
		$where = '1=1';
	//die($seek.$where);
		return $this->field($field)->where($seek.$where)->order('sort desc')->limit($page)->select();
	
	}
	/**
	 * 插入一条数据
	 * @param array $data
	 * @return Ambigous <mixed, boolean, string, false, number>
	 */
	public function insert(array $data)
	{
		//字段
		$field = array(
				'td_id',
				'td_name',
				'td_head_img',
				'td_intro_img',
				'td_text',
				'sort',
				'td_content',
		);
			
		//字段过滤
		$data = $this->CheckField($data, $field);

		//添加时间
		$data['add_time'] = time();
	
		return $this->add($data);
			
	}
	/**
	 * 更新一条数据
	 */
	public function update(array $data, $id)
	{
	
		//字段
		$field = array(
				'td_name',
				'td_head_img',
				'td_intro_img',
				'td_text',
				'sort',
				'td_content',
		);
	
		//字段过滤
		$data = $this->CheckField($data, $field);
	
		//条件
		$where = $this->key.'='.$id;
			
	
		return $this->where($where)->save($data);
	
	}
	/**
	 * 获取团队信息
	 * @param unknown $id
	 * @return Ambigous <mixed, boolean, NULL, multitype:, unknown, string>
	 */
	public function getRowById($id)
	{
		//字段
		$field = array(
				'td_id',
				'td_name',
				'td_head_img',
				'td_intro_img',
				'td_text',
				'sort',
				'td_content',
	
		);
	
		//条件
		$where = $this->key."=".$id;
	
		return $this->field($field)->where($where)->find();
	}
	/**
	 * 删除控制
	 * @param unknown $id
	 * @return Ambigous <mixed, boolean, false, number>
	 */
	public function del($id)
	{
			
		//单选
		if ( !is_array($id) )
		{
	
			return $this->delete($id);
		}
		//多选
		else
		{
	
			$idStr = implode(',', $id);
			//die($idStr);
			return $this->where("td_id in (".$idStr.")")->delete();
	
		}
			
	}
}


?>